package zuoye1;

public class TryCatchDemo {
    public static void main(String[] args) {
        /*
        try {
            String line = null;
            String line1 = " ";
            String line2 = "123";
            System.out.println(line1.charAt(1));
            System.out.println(line.length());
            System.out.println(line2);
        }catch (NullPointerException e){
            System.out.println("出现空指针异常");
        }catch (StringIndexOutOfBoundsException e){
            System.out.println("下标越界异常");
        }catch (Exception e){
            System.out.println("出现异常");
        }

         */
        try {
            String line = null;
            String line1 = " ";
            String line2 = "123;";
            System.out.println(line.length());
            System.out.println(line1.charAt(1));
            System.out.println(line2);
        }catch (NullPointerException e){
            System.out.println("空指针异常");
        }catch (IndexOutOfBoundsException e){
            System.out.println("下标越界");
        }catch (Exception e){
            System.out.println("出现异常");
        }



    }
}
